if /I "%1" == "-h" (
	call :usage
	exit /B 1
)

reg import misc\set_cmdrc.reg 2>nul
call :append_or_update_alias

call common\function.bat sync_cmake

call :copy_nuget_config
echo Done.

exit /B 

:usage
	echo "jenny update"
	echo "    update jenny to the latest"
	exit /B 1
	
:append_or_update_alias
	set path_cmd_line="@path %%USERPROFILE%%\.jenny\jenny;%%PATH%%"
	set path_cmd_line=!path_cmd_line:~1,-1!
	for /F "eol= tokens=1 delims=" %%i in (..\..\cmdrc.bat) do (
		if "%%i" == "!path_cmd_line!" exit /B
	)
	echo !path_cmd_line!>> ..\..\cmdrc.bat
	
	exit /B !errorlevel!
	

:copy_nuget_config
	if not exist ..\NuGet.config copy misc\NuGet.config ..
	echo echo you may need to set account info in %%USERPROFILE%%\.jenny\NuGet.config manually

	exit /B !errorlevel!
